package com.tul.exercise.base.fanclass.eg3;

import java.util.ArrayList;
import java.util.Random;
import static com.tul.exercise.base.utils.Print.print;

/**
 * @ClassName RandomList
 * @Description TODO
 * @Author tul 2018/10/16
 * @Version 1.0
 **/
public class RandomList<T> {
    private ArrayList<T> sotrage = new ArrayList<>();

    // 随机数产出器
    private Random rand = new Random(47);

    public void add(T item) {
        sotrage.add(item);
    }

    public T select() {
        return sotrage.get(rand.nextInt(sotrage.size()));
    }

    public static void main(String[] args) {
        RandomList<String> list = new RandomList<>();

        String str = "xss ll slajglasj sss tul ias aa ";
        for(String word:str.split(" ")) {
            list.add(word);
        }

        for(int i=0;i<11;i++) {
            print(list.select());
        }
    }

}
